package Java8实战._1_并行流._1_将顺序流转化为并行流;

import java.util.stream.Stream;

public class _1_将顺序流转化为并行流 {

    public static void main(String[] args) {

        System.out.println(parallelSum(5));
    }

    public static long parallelSum(long n){

        return Stream.iterate(1l, i -> i + 1)
                .limit(n)
                .parallel()
                .reduce(0l,Long::sum)
                ;
    }
}
